import React,{Component} from 'react';
import { Grid } from 'antd-mobile';
import './grid.css';
class GridExample extends Component{
  constructor(props){
    super(props)
  }
  getUrlParam(name){
    let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    let hrefSeach='';
    if(window.location.href.indexOf('?')>0){
      hrefSeach = window.location.href.split('?')[1];
    }else{
      return;
    }
    let rl = hrefSeach.match(reg);
    if (rl != null) return decodeURI(rl[2]); return null;
  }
  render(){
    const size=this.props.data.length
    const data = Array.from(new Array(size)).map((_val, i) => ({
            icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
            text: this.props.data[i].name,
            url:this.props.data[i].url,
          }));
    return <Grid data={data} columnNum={this.props.num} hasLine={false} isCarousel onClick={_el => window.location.href=_el.url} />
  }
}
export default GridExample;